import request from '..'
import { IAccount, ILoginResult, Menu, UserInfo } from './type'

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/',
  UserMenus = '/role/'
}

export function accountLoginRequest(account: IAccount) {
  return request.post<ILoginResult>({
    url: LoginAPI.AccountLogin,
    data: account
  })
}

export function getUserInfoById(id: number) {
  return request.get<UserInfo>({
    url: LoginAPI.LoginUserInfo + id
  })
}

export function getMenusByRoleId(id: number) {
  return request.get<Menu>({
    url: LoginAPI.UserMenus + id + '/menu'
  })
}
